{% extends 'pages/__base.html' %}

{% block __base %}

{% from 'tools/card.html' import nonModal %}

    {% set form_html %}
        <form method="POST" id="loginform">
            <div class="input-group mb-3">
                <input class="form-control" placeholder="用户名" id="username">
            </div>
            <div class="input-group mb-3">
                <input type="password" class="form-control" placeholder="密码" id="password">
            </div>
            <div class="row">
                <div class="col-4">
                    <button class="btn btn-primary btn-block">登录</button>
                </div>
                <div class="col-4">
                    <a class="btn btn-primary btn-block" href="{{ url_for('auth.register') }}">注册</a>
                </div>
            </div>
        </form>

        <script>
            Event('loginform','submit', (event)=>{
               data=packDataById('username','password')
               fetchPost('{{ url_for('api.login') }}',data).then((json)=>{
                   flash(json.msg)
               })
            })
        </script>
    {% endset %}


    <div class="login-page"><div class="login-box">
    {{ nonModal(head='<h4>登录</h4>' | safe,
        body=form_html,collapse=False) }}
    </div></div>


{% endblock %}